package com.itheima.aop;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class Aspect1 {

    @Before("execution(* com.itheima.service.impl.*.*(..))")
    public void before(){
        log.info("前置通知......");
    }

    @Around("execution(* com.itheima.service.impl.*.*(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        log.info("环绕前置通知......");
        Object proceed = pjp.proceed();
        log.info("环绕后置通知......");
        return proceed;
    }

    @After("execution(* com.itheima.service.impl.*.*(..))")
    public void After(){
        log.info("后置通知（一定会执行）......");
    }

    @AfterReturning("execution(* com.itheima.service.impl.*.*(..))")
    public void AfterReturning(){
        log.info("AfterReturning后置通知（出异常，不执行）......");
    }

    @AfterThrowing("execution(* com.itheima.service.impl.*.*(..))")
    public void AfterThrowing(){
        log.info("AfterThrowing后置通知（出异常，才执行）......");
    }
}
